#include "stdio.h"
#include "stdlib.h"
#include "malloc.h"

// 5个常量定义
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define OVERFLOW -1

//类型定义
typedef int Status;
typedef int ElemType;

//测试程序长度定义
#define LONGTH 5

// 链表的类型
typedef struct LNode
{
    ElemType data;
    struct LNode *next;
} LNode, *LinkList;

// 创建包含n个元素的链表L,元素值存储在data数组中
Status create(LinkList &L, ElemType *data, int n)
{
    LNode *q, *q;
    int i;
    if (n < 0)
        return ERROR;
    L = NULL;
    p = L;
    for (i = 0; i < n; i++)
    {
        q = (LNode *)malloc(sizeof(LNode));
        if (NULL == q)
            return OVERFLOW;
        q->data = data[i];
        q->next = NULL;
        if (NULL == p)
            L = q;
        else
            p->next = q;
        p = q;
    }
    return OK;
}